<?php

namespace control;
/*
*入职记录类
*/

class staffEntryRecordClass extends adIndexClass
{
    private const page = 'staffEntryRecord';
    private const table = 'staff_entry_record';
    private const title = '入职记录';
    public array $stateOption = ['草稿', '审核中', '已通过'];

    /*列表-查询条件*/
    public function home()
    {
        //生成查询表单
        $html =
            text(array("name" => "orderNo", "title" => "入职单号")) .
            text(array("name" => "name", "title" => "姓名")) .
            selectMultiple(array("name" => "jobId", "title" => "拟任职位", "table" => "job", 'sqlField' => 'name', 'sqlId' => 'id')) .
            text(array("name" => "createTime", 'laydate' => ['type' => 'date', 'range' => '~'], "title" => "申请日期")) .
            select(array("name" => "state", "title" => "状态", "option" => $this->stateOption));
        //返回
        return $this->homeFun($this->search($html));
    }

    /*客户列表-查询结果*/
    public function homeSearch()
    {
        //like查询数组
        $like = array(
            "a.orderNo" => $this->post('orderNo'),
            "b.name" => $this->post('name'),//姓名
        );
        //全等查询数组
        $equal = array(
            "a.state" => $this->post('state'),//状态
            "a.jobId" => $this->post('jobId'),//拟任职位
        );
        $and = "";
        if ($this->post('createTime')) {
            $and .= self::timeComparison($this->post('createTime'), field: 'a.time');
        }
        //排序
        $orderBy = $this->orderBy(array(
            "search" => $this->post('orderBy') ?? null,
            "default" => "申请日期降序",
            "array" => array(
                "a.time" => array("desc" => "申请日期降序", 'site' => 5),
            ),
        ));
        //获取查询结果
        $where = search(array("like" => $like, "=" => $equal)) . $and;
        $page = $this->page(array("table" => self::table . " as a join talent_pool as b on a.talentId = b.id", 'field' => " a.*,b.name", "where" => $where, "order" => $orderBy['orderBy']));
        //获取表头
        $checkAll = $this->checkAll("listForm", "listId");
        $tr[] = array($checkAll, '入职单号', "姓名", "拟任职位", "申请日期", '状态');
        //获取记录
        $url = root . "control/adIndex.html?cla=" . self::page;
        foreach ($page['array'] as $array) {
            //列表控件
            $dominate = array(
                "box" => array("name" => "listId", "value" => $array['id']),
                "edit" => $array['state'] == '草稿' ? array("title" => "编辑", "click" => "newIframe('" . self::title . "详情','" . $this->root . 'control/adIndex.html?cla=talentPool&fun=entry&source=' . self::page . "&id=" . $array['talentId'] . "')") : [],
                "detail" => array("title" => self::title . "详情", "click" => "newIframe('" . self::title . "详情','" . $url . "&fun=detail&id=" . $array['id'] . "')"),
                'print' => array('title' => '打印', 'click' => "window.open('" . root . "control/adIndex.html?cla=" . self::page . "&fun=printPage&id={$array['id']}')"),
            );
            $job = query('job', " id = '$array[jobId]'");
            $tr[] = array($this->dominate($dominate), $array['orderNo'], $array['name'], $job['name'], $array['time'], $array['state']);
        }
        //控件
        $button = "";
        if ($this->power(self::page, "del")) {
            $button .= "<span class='spanButton' onclick=\"layer('{$this->get('cla')}', 'operate', {'act': 'del'})\">删除</span>\n";
        }
        //返回
        $json['html'] = $page['hint'] . $button . "<form name='listForm'>" . space . $this->tableMany(array("tr" => $tr, 'orderBySign' => $orderBy)) . "</form>" . $page['button'] . clear;
        return json_encode($json, 320);
    }

    /**
     * 审核按钮
     * @param $info
     * @return array
     */
    public function auditButton($info): array
    {
        $button = [];
        if ($info['state'] == '草稿' || auditClass::auditFlag(self::table, $info['id'], 'selfChoose')) {
            $button[] = [
                "name" => '提交审批',
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                'style' => 'li-btn-blue-bg',
                "post" => ["act" => 'start', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'name' => '入职申请',
                    'table' => self::table,
                    'process' => [
                        // 预览函数
                        'detail' => [
                            'cla' => $this->get('cla'),
                            'fun' => 'detail'
                        ],
                        // 保存函数
                        'save' => [
                            'cla' => 'talentPool',
                            'fun' => 'entryEdit'
                        ],
                        //执行发起时验证函数
                        'before' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                        //完成发起后执行函数
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => 'prepare',
                            'data' => ['id' => $info['id']]
                        ],
                    ],
                ], 320))],
            ];
        }
// 审批并判断是否有权限
        if ($info['state'] == '审核中' && auditClass::auditFlag(self::table, $info['id'])) {
            $button[] = [
                "name" => '审批',
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                // 以下参数固定格式
                "post" => ["act" => 'approval', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'table' => self::table,
                    // 当前状态
                    'state' => $info['state'],
                    // 变更
                    'field' => ['state'],   //变更字段 可多个
                    'value' => [
                        'state' => ['草稿', '已通过'],
                    ],
                    // 审核时回调
                    'process' => [
                        //执行首次审核时验证
                        'before' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                        //执行末次审核后处理
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => 'finish',
                            'data' => ['id' => $info['id']]
                        ],
                    ],
                ], 320))],
                'style' => 'li-btn-blue-bg',
            ];
            $button[] = [
                "name" => '添加审批人',
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'addApprover', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'table' => self::table
                ], 320))],
            ];
            $button[] = [
                "name" => '转交',
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'transfer', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'table' => self::table
                ], 320))],
            ];

        }

        // 撤销审批
        if (auditClass::auditFlag(self::table, $info['id'], 'cancel') && $info['state'] == '审核中') {
            $button[] = [
                "name" => '撤销审批',
                "type" => "弹出层",
                "cla" => 'audit',
                "fun" => "operate",
                "post" => ["act" => 'cancel', "id" => $info['id'], 'body' => self::encryptDecrypt(json_encode([
                    'table' => self::table,
                    // 当前状态
                    'state' => $info['state'],
                    // 变更
                    'field' => ['state'],   //变更字段 可多个
                    'value' => [
                        'state' => ['草稿'],
                    ],
                    'process' => [
                        //完成发起后执行函数
                        'after' => [
                            'cla' => $this->get('cla'),
                            'fun' => ''
                        ],
                    ],
                ], 320))],
            ];
        }

        return $button;
    }

    /*详情页*/
    public function detail(): string
    {
        $info = query(self::table, " id = '{$this->get('id')}'");
        if (empty($info['id'])) {
            $html = '未找到此' . self::title;
        } else {
            $talentObj = new talentPoolClass();
            //菜单
            $talent = query('talent_pool', " id = '$info[talentId]'");
            //菜单
            $data = array(
                "id" => $info['id'],
                "title" => self::title . '详情',
            );
            $button = [];
            //审核按钮
            $button = array_merge($button, $this->auditButton($info));
            if ($this->power(self::page, "edit") && $info['state'] == '草稿') {

                //按钮
                $button[] = [
                    "name" => "查看人才库",
                    "type" => "顶部页卡",
                    "cla" => $this->get('cla'),
                    "title" => "人才库详情",
                    "url" => $this->root . 'control/adIndex.html?cla=talentPool&fun=detail&id=' . $info['talentId'],
                ];
                //按钮
                $button[] = [
                    "name" => "编辑",
                    "type" => "顶部页卡",
                    "title" => "编辑用户",
                    "url" => $this->root . 'control/adIndex.html?cla=talentPool&fun=entry&source=' . self::page . '&id=' . $info['talentId'],
                ];
            }
            if ($this->power(self::page, "del") && $info['state'] == '草稿') {
                //按钮
                $button[] = [
                    "name" => "删除",
                    "type" => "弹出层",
                    "cla" => $this->get('cla'),
                    "fun" => "operate",
                    "post" => ["act" => 'del', "id" => $info['id']],
                ];
            }
            $ico = [];
            $all = find(array('table' => 'file', 'where' => "targetId = '$talent[id]' and target in ('入职登记表','身份证正面','身份证背面','毕业证','学位证','银行卡','离职证明','体检报告','职称证书','竞业限制协议')"));
            foreach ($all['array'] as $array) {
                $ico[$array['target']] = $array['src'];
            }
            $photo = array(
                array("title" => "身份证正面", 'type' => '身份证正面', "url" => $ico['身份证正面'] ?? ''),
                array("title" => "身份证背面", 'type' => '身份证背面', "url" => $ico['身份证背面'] ?? ''),
                array("title" => "毕业证", 'type' => '毕业证', "url" => $ico['毕业证'] ?? ''),
                array("title" => "学位证", 'type' => '学位证', "url" => $ico['学位证'] ?? ''),
                array("title" => "银行卡", 'type' => '银行卡', "url" => $ico['银行卡'] ?? ''),
                array("title" => "入职登记表", 'type' => '入职登记表', "url" => $ico['入职登记表'] ?? ''),
                array("title" => "离职证明", 'type' => '离职证明', "url" => $ico['离职证明'] ?? ''),
                array("title" => "体检报告", 'type' => '体检报告', "url" => $ico['体检报告'] ?? ''),
                array("title" => "职称证书", 'type' => '职称证书', "url" => $ico['职称证书'] ?? ''),
                array("title" => "竞业限制协议", 'type' => '竞业限制协议', "url" => $ico['竞业限制协议'] ?? ''),
            );
            //职位
            $job = query('job', " id = '$info[jobId]'");
            $staffFormal = query('staff_formal', "talentId = '$talent[id]' order by time desc");
            $audit = query('audit', " targetId = '$info[id]'");
            //生成表单
            $data['html'] = $this->tableShow(array(
                "button" => $button,
                array(
                    array(
                        "姓名" => $talent['name'],
                        "入职日期" => $info['entryDate'],
                        "转正日期" => $staffFormal['confirmDate'],
                    ),
                    array(
                        "合同类型" => $info['contractType'],
                        "合同期限" => $info['contractLimitType'] == '固定期限' ? $info['contractLimitType'] . $info['contractYear'] . '月' : $info['contractLimitType'],
                        "拟任职位" => $job['name'],
                    ),
                    array(
                        "职位类型" => $job['type'],
                        "所属部门" => departmentClass::getTypeName($job['departmentId']),
                        "直属上级" => self::findStaff($info['managerId']),
                    ),
                    array(
                        "劳动报酬" => $info['workSalary'],
                        "社会保险" => $info['insure'],
                    ),
                    array(
                        "工作备注" => $info['text'],
                    ),
                ),
                "系统信息" => array(
                    array(
                        "单据编号" => $info['orderNo'],
                        "申请人部门" => $info['deptName'],
                        "申请人" => self::findStaff($info['stid']),
                    ),
                    array(
                        "创建时间" => $info['time'],
                        "提交时间" => self::null($audit['commitTime']),
                        "状态" => $info['state'],
                    ),
                ),
                "入职资料" => array(
                    array(
                        $talentObj->photo($photo)
                    )
                ),
                '流程' => array(
                    array(
                        auditClass::auditRecord(self::table, $info['id'])
                    )
                ),
            ));

            //生成页面
            $html = $this->tab($data);
        }
        //返回
        return $html;
    }

    /**
     * 审批通过后生成staff表数据
     */
    public function insertStaff($info, $workFlow = '已复核')
    {
        $talent = query('talent_pool', " id = '$info[talentId]'");
        $staff = query('staff', " talentId = '$info[talentId]'");
        if (strtotime($info['endDate']) < time()) {
            //试用期小于当前时间
            $state = '转正';
        } else {
            $state = '试用';
        }
        if (!empty($staff['stid'])) {
            //离职后又入职的情况
            $warn = static::update(array(
                'table' => 'staff',
                'field' => [
                    'quitDay' => '',
                    'jobId' => $info['jobId'],
                    'state' => $state,
                    'name' => $talent['name'],
                    'tel' => $talent['tel'],
                    'manager' => $info['managerId'] == $staff['stid'] ? '' : $info['managerId'],
                ],
                'where' => " stid = '$staff[stid]'"
            ));
            $stid = $staff['stid'];
        } else {
            $userNo = codeTemplateClass::generateCode('staffProfiles', [
                'prefix' => 'YM' . date('Ymd'),
                'table' => 'staff',
                'field' => 'orderNo',
                'where' => '',
            ], []);
            $stid = self::getId();
            $warn = insert(array(
                'table' => 'staff',
                'field' => [
                    'ico' => 'img/websiteImg/replaceHead.jpg',
                    'stid' => $stid,
                    'orderNo' => $userNo,
                    'jobId' => $info['jobId'],
                    'talentId' => $info['talentId'],
                    'state' => $state,
                    'name' => $talent['name'],
                    'tel' => $talent['tel'],
                    'manager' => $info['managerId'],
                    'workFlow' => $workFlow
                ]
            ));
        }
        if (!in_array($warn, ['新增成功', '更新成功'])) {
            return '';
        }
        return $stid;
    }

    /**
     * 提交审核成功后做的操作
     */
    public function prepare($data)
    {
        //入职记录表
        $info = query(self::table, " id = '{$data['id']}'");
        //更新人才库状态为已提交审核
        static::update(array('table' => 'talent_pool', 'field' => ['workFlow' => 1, 'state' => '入职审批'], 'where' => " id = '$info[talentId]'"));
    }

    /**
     * 审批结束后需要执行的操作
     * @param $data
     */
    public function finish($data)
    {

        //入职记录表
        $info = query(self::table, " id = '$data[id]'");
        static::update(array('table' => 'talent_pool', 'field' => ['workFlow' => 2, 'state' => '已入职'], 'where' => " id = '$info[talentId]'"));
        //生成staff表数据
        $stid = $this->insertStaff($info);
        //生成合同
        $this->insertContract($stid, $info);
        //生成社会保险
        $this->insertInsure($stid, $info);
        //员工表
        $staff = query('staff', " talentId = '$info[talentId]'");
        //生成员工变动记录
        $this->insertStaffStateRecord($staff['stid'], '入职', $info['id'], $this->date);
    }

    /**
     * 生成合同
     */
    public function insertContract($stid, $info, $source = '新增')
    {
        $department = query('department', " id = '{$this->controlJob['departmentId']}'");

        $field = [
            'talentId' => $info['talentId'],
            'entryId' => $info['id'],
            'staffId' => $stid,
            'jobId' => $info['jobId'],
            'managerId' => $info['managerId'],
            'entryDate' => $info['entryDate'],
            'endDate' => $info['endDate'],
            'text' => $info['text'],
            'contractType' => $info['contractType'],
            'contractYear' => $info['contractYear'],
            'contractLimitType' => $info['contractLimitType'],
            'workSalary' => $info['workSalary'],
            'insure' => $info['insure'],
        ];
        if ($source == '导入') {
            $contract = query('staff_contract', "talentId = '$info[talentId]' and staffId = '$stid' order by endDate desc");
            if (!empty($contract['id'])) {
                return static::update(array(
                    'table' => 'staff_contract',
                    'field' => $field,
                    'where' => "id = '$contract[id]'"
                ));
            }
        }
        if ($source == '新增' || empty($contract['id'])) {
            $userNo = codeTemplateClass::generateCode('workContract', [
                'prefix' => 'LDHT' . date('Ymd'),
                'table' => 'staff_contract',
                'field' => 'orderNo',
                'where' => '',
            ], $field);
            $field = array_merge($field, [
                'orderNo' => $userNo,
                'stid' => $this->control['stid'],
                'deptName' => $department['name'],
                'state' => '草稿',
                'workFlow' => '待新签',
                'id' => suiji(),
            ]);
            return static::insert(array(
                'table' => 'staff_contract',
                'field' => $field
            ));
        }

        return false;
    }

    /**
     * 生成社会保险
     */
    public function insertInsure($stid, $info, $source = '新增')
    {
        $field = [
            'talentId' => $info['talentId'],
            'entryId' => $info['id'],
            'staffId' => $stid,
        ];
        if ($source == '导入') {
            $contract = query('staff_contract', "talentId = '$info[talentId]' and staffId = '$stid' order by endDate desc");
            if (!empty($contract['id'])) {
                return static::update(array(
                    'table' => 'staff_contract',
                    'field' => $field,
                    'where' => "id = '$contract[id]'"
                ));
            }
        }
        if ($source == '新增' || empty($contract['id'])) {
            $userNo = codeTemplateClass::generateCode('workInsure', [
                'prefix' => 'SHBX' . date('Ymd'),
                'table' => 'staff_insure',
                'field' => 'orderNo',
                'where' => '',
            ], $field);
            $field = array_merge($field, [
                'orderNo' => $userNo,
                'stid' => $this->control['stid'],
                'workFlow' => '待参保',
                'id' => suiji(),
            ]);
            return static::insert(array(
                'table' => 'staff_insure',
                'field' => $field
            ));
        }
        return false;
    }

    /**
     * 插入状态变动记录
     * @param $stid string 员工ID
     * @param $type string 变动类型
     * @param $sourceId string 来源ID
     * @param $recordDate string 变动日期
     */
    public function insertStaffStateRecord(string $stid, string $type, string $sourceId, string $recordDate)
    {
        $sourceTable = '';
        if ($type == '入职') {
            $sourceTable = 'staff_entry_record';
        } elseif ($type == '转正') {
            $sourceTable = 'staff_formal';
        } elseif ($type == '调岗') {
            $sourceTable = 'job_apply';
        } elseif ($type == '停薪留职') {
            $sourceTable = 'staff_stay_record';
        } elseif ($type == '离职') {
            $sourceTable = 'staff_quit_record';
        } elseif ($type == '上岗') {
            $sourceTable = 'staff_stay_record';
        }
        $info = query($sourceTable, " id = '$sourceId' order by time desc");
        static::insert(array(
            'table' => 'staff_state_record',
            'field' => [
                'id' => self::getId(),
                'stid' => $stid,
                'name' => self::findStaff($stid),
                'type' => $type,
                'sourceTable' => $sourceTable,
                'sourceId' => $sourceId,
                'orderNo' => $info['orderNo'],
                'recordDate' => $recordDate,
                'time' => $this->time,
            ]
        ));
    }

    // 操作中转
    public function operate()
    {
        $act = $this->post('act') ?? '';
        $pwd = false; // 需要密码
        $form = $power = '';
        switch ($act) {
            default:
                $act = 'del';
                $msg = '删除' . self::title;
                $title = self::page . 'Delete';
                $function = 'delete';
                $form = self::page . 'OperateForm, listForm';
                $power = '';
                break;
        }
        if (!$this->power(self::page, $act)) {
            $_SESSION['warn'] = '你还没有' . $msg . '的权限';
            $json = [
                'warn' => 2,
                'href' => root . 'control/adIndex.html?cla=' . $this->get('cla') . '&fun=home',
            ];
        } else {
            return $this->confirm([
                'title' => $title,
                'function' => $function,
                'form' => $form,
                'power' => $power,
                'pwd' => $pwd,
            ]);
        }

        resp:
        return json_encode($json, 320);
    }

    /**
     * 删除
     * @return bool|string
     */
    public function delete()
    {
        $array = $this->post('listId') ?? $this->post('id');
        if (!$this->power(self::page, "del")) {
            $json['warn'] = "你没有删除的权限";
        } elseif (empty($array)) {
            $json['warn'] = "你一个数据都没有选择呢";
        } else {
            $text = "";
            $x = 0;
            $array = is_array($array) ? $array : [$array];
            foreach ($array as $id) {
                $info = query(self::table, " id = '$id' ");
                if ($info['state'] != '草稿') {
                    $warn = "删除失败：不是草稿状态，暂不能删除";
                } else {
                    //删除audit表记录
                    delete(array('table' => 'audit', 'where' => "targetId = '$id'"));
                    $all = find(array('table' => 'file', 'where' => "targetId = '$id'"));
                    foreach ($all['array'] as $val) {
                        fileDelete($val['src']);
                        delete(array("table" => 'file', "where" => " id = '$val[id]' "));
                    }
                    //删除审批记录
                    delete(array("table" => "auditing_follow", "where" => " typeId = '$id' "));
                    //删除消息提醒
                    delete(array("table" => "message", "where" => " typeId = '$id' "));
                    //删除待办事项
                    delete(array("table" => "backlog", "where" => " typeId = '$id' "));
                    //最后删除基本参数
                    delete(array("table" => self::table, "where" => " id = '$id' "));
                    //删除合同
                    delete(array("table" => 'staff_contract', "where" => " entryId = '$id' "));
                    //更新人才库状态
                    update(array('table' => 'talent_pool', 'field' => ['workFlow' => 0], 'where' => "id = '$info[talentId]'"));
                    //返回
                    $warn = "删除成功";
                    $x++;
                }
                $text .= self::title . "ID【" . $info['id'] . "】" . $warn . "。<br>";
            }
            //添加日志
            $text = $this->control['name'] . "删除了" . self::title . "，结果如下：<br>" . $text;
            $this->logText(array("type" => self::page, "text" => $text));
            $_SESSION['warn'] = "删除了" . $x . "个" . self::title . "，详情见系统日志。";
            $json['warn'] = 2;
            $json['href'] = root . "control/adIndex.html?cla=" . $this->get('cla') . "&fun=home";
        }
        return json_encode($json, 320);
    }


    /**
     * 打印
     */
    public function printPage(): string
    {

        $info = query(self::table, " id = '{$this->get('id')}'");
        $talentPool = query('talent_pool', "id = '$info[talentId]'");
        $companyName = para('companyName');//公司名称
        $edHtml = '';
        $result = find(array('table' => "study_history", 'where' => "talentId = '{$talentPool['id']}' order by list asc"));
        $index = 0;
        foreach ($result['array'] as $array) {
            $index++;
            if ($index > 3) {
                break;
            }
            $edHtml .= <<<eof
 <tr class='have_border'>
                    <td colspan='2'>{$array['studyDate']}</td>
                    <td colspan='2'>{$array['college']}</td>
                    <td colspan='2'>{$array['major']}</td>
                </tr>
eof;
        }
        if ($index < 3) {
            $edHtml .= str_repeat(<<<eof
 <tr class='have_border'>
                    <td colspan='2'>&nbsp;</td>
                    <td colspan='2'></td>
                    <td colspan='2'></td>
                              </tr>
eof, (3 - $index));
        }
        $index = 0;
        $workHtml = '';
        $result = find(array('table' => "job_history", 'where' => "talentId = '{$talentPool['id']}' order by list asc"));
        foreach ($result['array'] as $array) {
            $index++;
            if ($index > 3) {
                break;
            }
            $workHtml .= <<<eof
 <tr class='have_border'>
                    <td colspan='2'>{$array['workDate']}</td>
                    <td colspan='2'>{$array['companyName']}</td>
                    <td colspan='2'>{$array['position']}</td>
                </tr>
eof;
        }
        if ($index < 3) {
            $workHtml .= str_repeat(<<<eof
 <tr class='have_border'>
                    <td colspan='2'>&nbsp;</td>
                    <td colspan='2'></td>
                    <td colspan='2'></td>
                              </tr>
eof, (3 - $index));
        }

        $job = query('job', "id = '$info[jobId]'");
        $departmentName = departmentClass::getTypeName($job['departmentId']);
        $auditRecord = '';
        $all = find(array('table' => 'auditing_follow', 'where' => "typeId = '$info[id]' order by time asc"));
        foreach ($all['array'] as $array) {
            $auditRecord .= "<p>" . $array['text'] . '，' . $array['time'] . "</p>";
        }

        $talentPool['height'] = $talentPool['height'] > 0 ? $talentPool['height'] : '';
        $talentPool['weight'] = $talentPool['weight'] > 0 ? $talentPool['weight'] : '';
        //二维码
        $url = root . 'pay/wxpay/wxScanPng.php?url=' . urlencode("source=staff_entry_record&id=" . $info['id']);
        $staffEntryRecordText = para('staffEntryRecordText');
        $divHtml = "
                 <div>
                      <div class='printTitle' style='margin-top: 0'>{$companyName}</div>
                      <div class='printSubTitle' style='position: relative'>员工入职登记表<div style='position: absolute;font-size: 14px;top: -30px'>{$info['orderNo']}</div><div style='position: absolute;top: -46px;right: 0'><img alt='二维码' style='width: 80px;vertical-align: top' src='$url'></div></div>
                 </div>
                 <div class='table-top-title'></div>
              <table class='printTable'  data-op-type='block-box'>
                <tbody class='nop-fill-box'>
               <tr class='have_border'>
                   <td>姓名</td>
                   <td>{$talentPool['name']}</td>
                   <td>性别</td>
                   <td>{$talentPool['sex']}</td>
                   <td>出生年月</td>
                   <td>{$talentPool['birthDay']}</td>
                   <td rowspan='4'></td>
                </tr>
                 <tr class='have_border'>
                    <td>民族</td>
                    <td>{$talentPool['nation']}</td>
                    <td>婚否</td>
                    <td>{$talentPool['marriage']}</td>
                    <td>文化程度</td>
                    <td>{$talentPool['education']}</td>
                </tr>
                <tr class='have_border'>
                    <td>职称</td>
                    <td>{$talentPool['jobTitle']}</td>
                    <td>专业</td>
                    <td>{$talentPool['major']}</td>
                    <td>身高(cm)</td>
                    <td>{$talentPool['height']}</td>
                </tr>
                <tr class='have_border'>
                    <td>体重(kg)</td>
                    <td>{$talentPool['weight']}</td>
                    <td>健康状况</td>
                    <td>{$talentPool['health']}</td>
                    <td>政治面貌</td>
                    <td>{$talentPool['politicsStatus']}</td>
                </tr>
                <tr class='have_border'>
                    <td>籍贯</td>
                    <td>{$talentPool['homeTown']}</td>
                    <td>邮箱</td>
                    <td>{$talentPool['email']}</td>
                    <td>联系电话</td>
                    <td colspan='2'>{$talentPool['tel']}</td>
                </tr>
                 <tr class='have_border'>
                    <td>身份证号</td>
                    <td colspan='3'>{$talentPool['idCard']}</td>
                      <td>竞业协议</td>
                    <td colspan='2'>{$talentPool['isProhibition']}</td>
                </tr>
                <tr class='have_border'>
                    <td>户口所在地</td>
                    <td  colspan='3'>{$talentPool['residenceAddress']}</td>
                    <td>户口性质</td>
                    <td colspan='2'>{$talentPool['residenceType']}</td>
                </tr>
                <tr class='have_border'>
                    <td>通讯地址</td>
                    <td  colspan='6'>{$talentPool['liveAddress']}</td>
                  
                </tr>
                <tr class='have_border'>
                    <td>紧急联系人</td>
                    <td colspan='2'>{$talentPool['secContactName']}</td>
                    <td>关系</td>
                    <td>{$talentPool['secContactRelation']}</td>
                    <td>联系电话</td>
                    <td>{$talentPool['secContactTel']}</td>
                </tr>
                <tr class='have_border'>
                    <td rowspan='4'>学历背景</td>
                    <td colspan='2'>起止时间</td>
                    <td colspan='2'>毕业院校</td>
                    <td colspan='2'>专业</td>
                </tr>
                {$edHtml}
                 <tr class='have_border'>
                    <td rowspan='4'>工作经历</td>
                    <td colspan='2'>起止日期</td>
                    <td colspan='2'>工作单位名称</td>
                    <td colspan='2'>职务</td>
                </tr>
                {$workHtml}
                
                <tr class='have_border'>
                    <td colspan='7'>
                        <div>
                            <p>说明：</p>
                            <p>$staffEntryRecordText</p>
                            <p>&nbsp;</p>
                            <p class='right'>签字：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;日期：&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</p>
                            
                        </div>
                    </td>
                </tr>
                <tr class='have_border'>
                    <td colspan='7' style='text-align: center'>以下由公司填写</td>
                </tr><tr class='have_border'>
                    <td>入职部门</td>
                    <td colspan='2'>{$departmentName}</td>
                    <td>职位</td>
                    <td>{$job['name']}</td>
                    <td>劳动报酬</td>
                    <td>{$info['workSalary']}</td>
                </tr>
                <tr class='have_border'>
                    <td>入职日期</td>
                    <td colspan='2'>{$info['entryDate']}</td>
                    <td>试用期至</td>
                    <td>{$info['endDate']}</td>
                    <td>社会保险</td>
                    <td>{$info['insure']}</td>
                </tr>
                <tr class='have_border'>
                    <td>审批记录</td>
                    <td colspan='6'>
                        <div style='min-height: 100px'>{$auditRecord}</div>
                    </td>
                </tr>
               </tbody>
              </table>
            ";
        $html = <<<eof
                    <div id="content-box" style="display: none">
                        <div data-op-type='new-page'></div>
                    <!--    <div data-op-type="pendants">&lt;!&ndash; 定义页面部件（页眉/页脚/书签/水印背景等） &ndash;&gt;-->
                    <!--        <div class='pendant-title'>实发工资表</div>-->
                    <!--    </div>-->
                       {$divHtml}
                    </div>
                  <style>
                  .footer-ul-parent{float: right;margin-right: 10px}
                  .footer-ul li{margin-top: 10px}
                  .table-top-title{
                    height: 15px;
                    line-height: 15px;
                    font-size: 14px;
                    margin-top: 10px;
                  }
                  .table-top-title>ul>li{float: left;width: 250px;}
                  .printTable{table-layout: fixed}
                  .printTable td{line-height: 25px}
                  .printSubTitle{font-size: 20px;font-weight: normal}
</style>
eof;
        $print = new printClass();

        return $print->showPrint($html, 'portrait', ['padding' => "7mm 10mm 5mm 10mm"]);
    }
}

